package com.jrx.anytxn.param.mapper.ext;


import com.jrx.anytxn.param.entity.TlThirdBillDetail;
import com.jrx.anytxn.param.mapper.base.TlThirdBillDetailMapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface ExtTlThirdBillDetailMapper extends TlThirdBillDetailMapper {

    int deleteByBusDate(@Param("businessDate") Date businessDate, @Param("thirdChannel") String thirdChannel);


    /**
     * 根据入库处理日期删除信息
     * @param dealDate
     * @param thirdChannel
     * @return
     */
    int deleteByDealDate(@Param("dealDate") String dealDate, @Param("thirdChannel") String thirdChannel);

    int insertbatch(List<TlThirdBillDetail> item);

    TlThirdBillDetail selectByThirdSeq(@Param("thirdSeq") String thirdSeq,
                                       @Param("tenantId") String tenantId,
                                       @Param("thirdChannel") String thirdChannel);


    TlThirdBillDetail selectByThirdSeqAndType(@Param("thirdSeq") String thirdSeq,
                                       @Param("tenantId") String tenantId,
                                       @Param("thirdChannel") String thirdChannel,
                                       @Param("transactionType") String transactionType);

    void batchUpdate(List<TlThirdBillDetail> item);

    BigDecimal sumByBusinessDate(String tenantId, Date businessDate,String thirdChannel);

    Integer countByBusinessDate(String tenantId, Date businessDate,String thirdChannel);

    BigDecimal sumByBusinessDateAndType(String tenantId, Date businessDate, String type,String thirdChannel);

    Integer countByBusinessDateAndType(String tenantId, Date businessDate, String type,String thirdChannel);

    BigDecimal sumByBusinessDateAndTypeAndStatus(String tenantId, Date businessDate, String type, String status,String thirdChannel);

    Integer countByBusinessDateAndTypeAndStatus(String tenantId, Date businessDate, String type, String status,String thirdChannel);

    List<TlThirdBillDetail> selectByTenIdAndBusDateAndComFlag(@Param("tenantId") String tenantId,
                                                              @Param("businessDate") Date businessDate,
                                                              @Param("compareFlag") String compareFlag,
                                                              @Param("thirdChannel") String thirdChannel);

    /**
     * 根据业务日期更新比对状态
     *
     * @param compareFlag  String
     * @param dataFrom     String
     * @param businessDate Date
     * @return int
     */
    void updateComFlagByFromAndBusDateAndThirdChannel(@Param("compareFlag") String compareFlag,
                                                      @Param("dataFrom") String dataFrom,
                                                      @Param("businessDate") Date businessDate,
                                                      @Param("thirdChannel") String thirdChannel);

    List<TlThirdBillDetail> selectByBusinessDateForBatch(@Param("tenantId") String tenantId, @Param("businessDate") Date businessDate);

}